# Module for items that can be interacted with by the player.
# These will be added as contents into a plot

import imagecache

# Uninstantiatable base class.
# Subclasses must implement the fields:
#     image_path: where the image is stored
class Item:
    def __init__(*kwargs):
        import inspect
        caller = inspect.getouterframes(inspect.currentframe())[1][3]
        raise NotImplementedError(caller + ' must be implemented in subclass')

    def walkable(self):
        return True
        
    def get_image(self):
        return imagecache.get_image(self.image_path)
        
    def interact(self, game):
        pass

class Bed(Item):
    def __init__(self):
        self.image_path = "bed"
        
    def walkable(self):
        return False
    
    def interact(self, game):
        game.end_turn()
        
    
# Items that can be taken by the player
class TakeableItem(Item):
    def __init__(self, item, image_path):
        self.item = item
        self.image_path = image_path
    
    # take this item
    def interact(self, game):
        game.field.get(game.player.get_tile_x(), game.player.get_tile_y()).remove_content(self)
        game.player.inventory.add(self.item)